package com.cedifie.lendapp.utils.helper

import com.cedifie.lendapp.MyApplication
import com.cedifie.lendapp.R
import com.cedifie.lib_permission.Permission
import org.json.JSONArray
import org.json.JSONObject

object PermissionHelper {


    /**
     * sms 权限
     */
    fun getCedSmsPermissionItem(): JSONObject{
        val item = JSONObject()
        item.put("isSystem",true)
        item.put("permission", Permission.READ_SMS)
        item.put("title", MyApplication.app.getString(R.string.permission_sms_title))
        item.put("icon",R.mipmap.icon_permission_list_sms)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", MyApplication.app.getString(R.string.permission_sms_1))
        obj1.put("des", MyApplication.app.getString(R.string.permission_sms_1_desc))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", "")
        obj2.put("des", MyApplication.app.getString(R.string.permission_sms_2_desc))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title", MyApplication.app.getString(R.string.permission_sms_3))
        obj3.put("des", MyApplication.app.getString(R.string.permission_sms_3_desc))
        msgArray.put(obj3)

        val obj4 = JSONObject()
        obj4.put("title", MyApplication.app.getString(R.string.permission_sms_4))
        obj4.put("des", MyApplication.app.getString(R.string.permission_sms_4_desc))
        msgArray.put(obj4)

        val obj5 = JSONObject()
        obj5.put("title", "")
        obj5.put("des", MyApplication.app.getString(R.string.permission_sms_5_desc))
        msgArray.put(obj5)

        item.put("msgList",msgArray)
        return item
    }

    /**
     * device
     */
    fun getCedDevicePermissionItem(): JSONObject{
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", "DEVICE INFORMATION")
        item.put("title", MyApplication.app.getString(R.string.permission_device_title))
        item.put("icon",R.mipmap.icon_permission_list_device)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", "")
        obj1.put("des", MyApplication.app.getString(R.string.permission_device_1_desc))
        msgArray.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title", "")
        obj2.put("des", MyApplication.app.getString(R.string.permission_device_2_desc))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title", "")
        obj3.put("des", MyApplication.app.getString(R.string.permission_device_3_desc))
        msgArray.put(obj3)

        val obj4 = JSONObject()
        obj4.put("title", "")
        obj4.put("des", MyApplication.app.getString(R.string.permission_device_4_desc))
        msgArray.put(obj4)

        val obj5 = JSONObject()
        obj5.put("title", "")
        obj5.put("des", MyApplication.app.getString(R.string.permission_device_5_desc))
        msgArray.put(obj5)

        val obj6 = JSONObject()
        obj6.put("title", "")
        obj6.put("des", MyApplication.app.getString(R.string.permission_device_6_desc))
        msgArray.put(obj6)

        item.put("msgList",msgArray)
        return item
    }

    /**
     * applist 权限
     */
    fun getCedAppListPermissionItem(): JSONObject{
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", "App List")
        item.put("title", MyApplication.app.getString(R.string.permission_app_list_title))
        item.put("icon",R.mipmap.icon_permission_list_app_list)
        val msgArray = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title", MyApplication.app.getString(R.string.permission_app_list_1))
        obj1.put("des", MyApplication.app.getString(R.string.permission_app_list_1_desc_1))
        msgArray.put(obj1)

        val item1 = JSONObject()
        item1.put("title", "")
        item1.put("des", MyApplication.app.getString(R.string.permission_app_list_1_desc_2))
        msgArray.put(item1)

        val item2 = JSONObject()
        item2.put("title", "")
        item2.put("des", MyApplication.app.getString(R.string.permission_app_list_1_desc_3))
        msgArray.put(item2)

        val obj2 = JSONObject()
        obj2.put("title", MyApplication.app.getString(R.string.permission_app_list_2))
        obj2.put("des", MyApplication.app.getString(R.string.permission_app_list_2_desc))
        msgArray.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title", MyApplication.app.getString(R.string.permission_app_list_3))
        obj3.put("des", MyApplication.app.getString(R.string.permission_app_list_3_desc))
        msgArray.put(obj3)

        val obj4 = JSONObject()
        obj4.put("title", MyApplication.app.getString(R.string.permission_app_list_4))
        obj4.put("des", MyApplication.app.getString(R.string.permission_app_list_4_desc))
        msgArray.put(obj4)

        item.put("msgList",msgArray)
        return item
    }

    /**
     * camera 权限
     */
    fun getCedCameraPermissionItem(): JSONObject{
        val item = JSONObject()
        item.put("isSystem",true)
        item.put("permission", Permission.CAMERA)
        item.put("icon", R.mipmap.icon_permission_list_camera)
        item.put("title",MyApplication.app.getString(R.string.permission_camera_title))

        val array = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title","")
        obj1.put("des",MyApplication.app.getString(R.string.permission_camera_1_desc))
        array.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title","")
        obj2.put("des",MyApplication.app.getString(R.string.permission_camera_2_desc))
        array.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title","")
        obj3.put("des",MyApplication.app.getString(R.string.permission_camera_3_desc))
        array.put(obj3)

        item.put("msgList",array)
        return item
    }

    /**
     * Storage
     */
    fun getCedStoragePermissionItem(): JSONObject{
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", "Storage")
        item.put("icon", R.mipmap.icon_permission_list_storage)
        item.put("title",MyApplication.app.getString(R.string.permission_storage_title))

        val array = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title","")
        obj1.put("des",MyApplication.app.getString(R.string.permission_storage_1_desc))
        array.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title","")
        obj2.put("des",MyApplication.app.getString(R.string.permission_storage_2_desc))
        array.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title","")
        obj3.put("des",MyApplication.app.getString(R.string.permission_storage_3_desc))
        array.put(obj3)

        val obj4 = JSONObject()
        obj4.put("title","")
        obj4.put("des",MyApplication.app.getString(R.string.permission_storage_4_desc))
        array.put(obj4)

        item.put("msgList",array)
        return item
    }

    /**
     * Contact
     */
    fun getCedContactPermissionItem(): JSONObject{
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", "Contact")
        item.put("icon", R.mipmap.icon_permission_list_contact)
        item.put("title",MyApplication.app.getString(R.string.permission_contact_title))

        val array = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title","")
        obj1.put("des",MyApplication.app.getString(R.string.permission_contact_1_desc))
        array.put(obj1)

        item.put("msgList",array)
        return item
    }

    /**
     * Photo album
     */
    fun getCedPhotoAlbumPermissionItem(): JSONObject{
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", "Photo Album")
        item.put("icon", R.mipmap.icon_permission_list_album)
        item.put("title",MyApplication.app.getString(R.string.permission_photo_album_title))

        val array = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title","")
        obj1.put("des",MyApplication.app.getString(R.string.permission_photo_album_1_desc))
        array.put(obj1)

        item.put("msgList",array)
        return item
    }

    /**
     * 电话号码申明
     */
    fun getCedPhoneNumberPermissionItem(): JSONObject{
        val item = JSONObject()
        item.put("isSystem",false)
        item.put("permission", "Phone Number Collection")
        item.put("icon", R.mipmap.icon_permission_phone_number)
        item.put("title",MyApplication.app.getString(R.string.permission_phone_number_title))

        val array = JSONArray()
        val obj1 = JSONObject()
        obj1.put("title","")
        obj1.put("des",MyApplication.app.getString(R.string.permission_phone_number_1_desc))
        array.put(obj1)

        val obj2 = JSONObject()
        obj2.put("title","")
        obj2.put("des",MyApplication.app.getString(R.string.permission_phone_number_2_desc))
        array.put(obj2)

        val obj3 = JSONObject()
        obj3.put("title","")
        obj3.put("des",MyApplication.app.getString(R.string.permission_phone_number_3_desc))
        array.put(obj3)

        val obj4 = JSONObject()
        obj4.put("title","")
        obj4.put("des",MyApplication.app.getString(R.string.permission_phone_number_4_desc))
        array.put(obj4)

        val obj5= JSONObject()
        obj5.put("title","")
        obj5.put("des",MyApplication.app.getString(R.string.permission_phone_number_5_desc))
        array.put(obj5)

        val obj6 = JSONObject()
        obj6.put("title","")
        obj6.put("des",MyApplication.app.getString(R.string.permission_phone_number_6_desc))
        array.put(obj6)

        val obj7 = JSONObject()
        obj7.put("title","")
        obj7.put("des",MyApplication.app.getString(R.string.permission_phone_number_7_desc))
        array.put(obj7)

        item.put("msgList",array)
        return item
    }
}